<?php
$db_config = require(__DIR__ . '/db-local.php');
$config = [
    'aliases' => [
        '@bower' => '@vendor/bower-asset',
        '@npm'   => '@vendor/npm-asset',
    ],
    'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',
    'components' => [
        // tools
        'db' => [
            'class' => 'yii\db\Connection',
            'dsn' => $db_config['db']['master']['dsn'],
            'username' => $db_config['db']['master']['username'],
            'password' => $db_config['db']['master']['password'],
            'charset' => 'utf8mb4',
            
            // 从库的通用配置
            'slaveConfig' => [
                'username' => $db_config['db']['slave']['username'],
                'password' => $db_config['db']['slave']['password'],
                'charset' => 'utf8mb4',
                'attributes' => [
                    // 从库的超时连接
                    PDO::ATTR_TIMEOUT => 3
                ]
            ],
            
            // 从库的dsn配置列表
            'slaves' => $db_config['db']['slave']['dsnlist']
        ],
        // 后台
        'admin_db' => [
            'class' => 'yii\db\Connection',
            'dsn' => $db_config['admin_db']['master']['dsn'],
            'username' => $db_config['admin_db']['master']['username'],
            'password' => $db_config['admin_db']['master']['password'],
            'charset' => 'utf8mb4',
            
            // 从库的通用配置
            'slaveConfig' => [
                'username' => $db_config['admin_db']['slave']['username'],
                'password' => $db_config['admin_db']['slave']['password'],
                'charset' => 'utf8mb4',
                'attributes' => [
                    // 从库的超时连接
                    PDO::ATTR_TIMEOUT => 3
                ]
            ],
            
            // 从库的dsn配置列表
            'slaves' => $db_config['admin_db']['slave']['dsnlist']
        ],
        // bx
        'bx_db' => [
            'class' => 'yii\db\Connection',
            'dsn' => $db_config['bx_db']['master']['dsn'],
            'username' => $db_config['bx_db']['master']['username'],
            'password' => $db_config['bx_db']['master']['password'],
            'charset' => 'utf8mb4',
            
            // 从库的通用配置
            'slaveConfig' => [
                'username' => $db_config['bx_db']['slave']['username'],
                'password' => $db_config['bx_db']['slave']['password'],
                'charset' => 'utf8mb4',
                'attributes' => [
                    // 从库的超时连接
                    PDO::ATTR_TIMEOUT => 3
                ]
            ],
            
            // 从库的dsn配置列表
            'slaves' => $db_config['bx_db']['slave']['dsnlist']
        ],
    ],
];
return $config;